home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Help / LaTeX Help.tcl < prev    next >
Encoding:
Text File  |  2000-11-30  |  7.8 KB  |  217 lines

  1. ## -*-Tcl-*-
  2.  # ==========================================================================
  3.  #  Help files for Alpha
  4.  # 
  5.  #  FILE: "LaTeX Help.tcl"
  6.  #                                    created: 10/17/00 {02:18:43 pm} 
  7.  #                                last update: 11/30/00 {07:49:20 pm} 
  8.  #  Description: 
  9.  #  
  10.  #  Script to view the local LaTeX .html manual, either in one's web
  11.  #  browser or using Alpha's parser.  Additional options include opening,
  12.  #  processing, or viewing the latex_<manual>.ext files.
  13.  # 
  14.  #  Author: Craig Barton Upright
  15.  #  E-mail: <cupright@princeton.edu>
  16.  #    mail: Princeton University, Department of Sociology
  17.  #          Princeton, New Jersey 08544
  18.  #     www: <http://www.princeton.edu/~cupright>
  19.  #  
  20.  # ==========================================================================
  21.  ##
  22.  
  23. catch {unset option}
  24.  
  25. set helpDir   [file join $HOME "LaTeX Docs"]
  26. set helpIntro [file join $HOME Help "LaTeX Help"]
  27.  
  28. # Is the "LaTeX manual" properly installed?
  29.  
  30. if {![file isdirectory $helpDir]} {
  31.     if {[file isfile $helpIntro]} {
  32.         help::openDirect $helpIntro
  33.     } else {
  34.         alertnote "The LaTeX Help file documents are not properly installed."
  35.     } 
  36.     unset helpDir helpIntro
  37.     return
  38. }
  39.  
  40. # If "helpMenuOptions" is 0, then the user wants all of possible options. 
  41. # If "helpMenuOptions" is 1, then the user wants to view the html manual. 
  42. # If "helpMenuOptions" is 2, then the user wants to view a pdf file if
  43. # there is one available.
  44.  
  45. if {$helpMenuOptions == 0} {
  46.     set options [list \
  47.       "Open  \"LaTeX Help\"  introduction" \
  48.       "View .html version of manual" \
  49.       ]
  50.     foreach f {guide menus bindings} {
  51.         # Open in TeX mode options.
  52.         if {[file exists [file join $helpDir latex_${f}.tex]]} {
  53.             lappend options "Open  \"latex_${f}.tex\"  file in TeX mode"
  54.         }
  55.     }
  56.     foreach f {guide menus bindings} {
  57.         # TeX the file options.
  58.         if {[file exists [file join $helpDir latex_${f}.tex]]} {
  59.             lappend options "TeX  \"latex_${f}.tex\"  file"
  60.         }
  61.     }
  62.     foreach f {guide menus bindings} {
  63.         # PdfTeX the file options.
  64.         if {[file exists [file join $helpDir latex_${f}.tex]]} {
  65.             lappend options "PdfTeX  \"latex_${f}.tex\"  file"
  66.         }
  67.     }
  68.     foreach f {guide menus bindings} {
  69.         # View dvi, ps, pdf options.
  70.         if {[file exists [file join $helpDir latex_${f}.dvi]]} {
  71.             lappend options "View  \"latex_${f}.dvi\"  file"
  72.         } 
  73.         if {[file exists [file join $helpDir latex_${f}.ps]]} {
  74.             lappend options "View  \"latex_${f}.ps\"  file"
  75.         } 
  76.         if {[file exists [file join $helpDir latex_${f}.pdf]]} {
  77.             lappend options "View  \"latex_${f}.pdf\"  file"
  78.         } 
  79.     }
  80.     foreach f {guide menus bindings} {
  81.         # Print options.
  82.         if {[file exists [file join $helpDir latex_${f}.dvi]]} {
  83.             lappend options "Print  \"latex_${f}.dvi\"  file"
  84.         } 
  85.         if {[file exists [file join $helpDir latex_${f}.ps]]} {
  86.             lappend options "Print  \"latex_${f}.ps\"  file"
  87.         } 
  88.     }
  89.     foreach f {guide menus bindings} {
  90.         # Dvips options.
  91.         if {[file exists [file join $helpDir latex_${f}.dvi]]} {
  92.             lappend options "Dvips  \"latex_${f}.dvi\"  file"
  93.         }
  94.     }
  95.     foreach f {guide menus bindings} {
  96.         # Dvipdf options.
  97.         if {[file exists [file join $helpDir latex_${f}.dvi]]} {
  98.             lappend options "Dvipdf  \"latex_${f}.dvi\"  file"
  99.         }
  100.     }
  101.     foreach f {guide menus bindings} {
  102.         # Distill options.
  103.         if {[file exists [file join $helpDir latex_${f}.ps]]} {
  104.             lappend options "Distill  \"latex_${f}.ps\"  file"
  105.         }
  106.     }
  107.     lappend options "(Set WWW preferences to avoid this dialog …)"
  108. } elseif {$helpMenuOptions == 1} {
  109.     if {[file exists [file join $helpDir docs latex_guide index.html]]} {
  110.         # The user wants to view the .html version of the manual.
  111.         set option "View .html version of manual"
  112.     } elseif {![catch {glob -dir [file join $f3] *.pdf} files]} {
  113.         # The .html version doesn't exist, and the user wants to view an
  114.         # existing .pdf file.
  115.         foreach f $files {
  116.             # There are multiple .pdf files to view.
  117.             lappend options "View  \"[file tail $f]"  file"
  118.         }
  119.         if {[llength $options] == 1} {
  120.             # There's only one .pdf file to view.
  121.             set option [lindex $options 0]
  122.         }
  123.     } 
  124. } elseif {$helpMenuOptions == 2} {
  125.     if {![catch {glob -dir [file join $f3] *.pdf} files]} {
  126.         # The user wants to view an existing .pdf file.
  127.         foreach f $files {
  128.             lappend options "View  \"[file tail $f]"  file"
  129.         }
  130.         if {[llength $options] == 1} {
  131.             # There's only one .pdf file to view.
  132.             set option [lindex $options 0]
  133.         } 
  134.     } elseif {[file exists [file join $helpDir docs latex_guide index.html]]} {
  135.         # There are no .pdf versions to view, and the user wants to view
  136.         # the existing .html file.
  137.         set option "View .html version of manual"
  138.     } 
  139.  
  140. if {![info exists option]} {
  141.     # We still have options.
  142.     set option [listpick \
  143.       -p "LaTeX manual options …" \
  144.       -L "View .html version of manual" $options]
  145. }
  146.  
  147. # Take care of some easy options first, then deal with the processing /
  148. # viewing options.  Processing relies on some procs from "latexComm.tcl",
  149. # which will be loaded if necessary.
  150.  
  151. if {$option == "(Set WWW preferences to avoid this dialog …)"} {
  152.     dialog::preferences preferences "WWW"
  153.     helpMenu "LaTeX Help"
  154. } elseif {$option == "Open  \"LaTeX Help\"  introduction"} {
  155.     help::openDirect $helpIntro
  156. } elseif {$option == "View .html version of manual"} {
  157.     help::openDirect [file join $helpDir docs latex_guide index.html]
  158. } elseif {[regexp "^(Open  \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
  159.     # Open the .tex file in TeX mode.
  160.     edit -r -c [file join $helpDir $filename]
  161. } elseif {[regexp "^(TeX  \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
  162.     # Typeset the file.
  163.     dummyTeX
  164.     alertnote "Be sure to process this file 3 times !!"
  165.     typesetFile [file join $helpDir $filename]
  166. } elseif {[regexp "^(PdfTeX  \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
  167.     # Typeset the file using pdfLaTeX.
  168.     dummyTeX
  169.     alertnote "Be sure to process this file 3 times !!"
  170.     pdflatexTEXFile [file join $helpDir $filename]
  171. } elseif {[regexp "^(View  \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
  172.     # View the file using the apps defined by TeX mode.
  173.     dummyTeX
  174.     switch -- [file extension $filename] {
  175.         ".dvi" {
  176.             viewDVIFile [file join $helpDir $filename]
  177.         }
  178.         ".ps" {
  179.             viewPSFile [file join $helpDir $filename]
  180.         }
  181.         ".pdf" {
  182.             viewPDFFile [file join $helpDir $filename]
  183.         }
  184.     }
  185. } elseif {[regexp "^(Print  \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
  186.     # View the file using the apps defined by TeX mode.
  187.     dummyTeX
  188.     switch -- [file extension $filename] {
  189.         ".dvi" {
  190.             printDVIFile [file join $helpDir $filename]
  191.         }
  192.         ".ps" {
  193.             printPSFile [file join $helpDir $filename]
  194.         }
  195.     }
  196. } elseif {[regexp "^(Dvips  \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
  197.     # Dvips the .dvi file.
  198.     dummyTeX
  199.     evalTeXScript dvips {DVI-to-PS filter} [file join $helpDir $filename]
  200. } elseif {[regexp "^(Dvipdf  \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
  201.     # Dvipdf the .dvi file.
  202.     dummyTeX
  203.     evalTeXScript dvipdf {DVI-to-PDF filter} [file join $helpDir $filename]
  204. } elseif {[regexp "^(Distill  \")(\[a-zA-Z_.\]*)" $option match dummy filename]} {
  205.     # Distill the .ps file
  206.     dummyTeX
  207.     distillPSFile [file join $helpDir $filename]
  208. }
  209.  
  210. unset helpDir helpIntro option
  211. catch {
  212.     unset options 
  213.     unset match dummy filename
  214. }
  215.  
  216.